'''
Created on Mar 21, 2012
Description: Example login web site with selenium RC
@author: Vu Dao
'''
import unittest
from Functions.loginPageFunc import openWebsite
from Functions.globalFunc import preCondition, endCondition, readData
import HTMLTestRunner
import time
from xlrd import open_workbook
book = open_workbook('../Database/data.xls')
sheet0=book.sheet_by_index(0)

class Ecom_5001(unittest.TestCase):
#class Ecom_5001():  

    def setUp(self):
        preCondition(self)
        
    def test_Ecom_5001(self):
        openWebsite(self)
        print "Open website successfully"
           
#        for index in range (1,sheet0.nrows):
#            a = readData("username", index = index)
#            print a
    
    def tearDown(self):
        endCondition(self)


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
#    unittest.main()
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5001)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Example login web site with selenium RC'
                    )
    runner.run(suite)